package work.mediway.mdm.core.constant;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2020/1/21
 */
public class MdmConstant {

    /**
     * 主键的数字部分长度
     */
    public static final int PRIMARY_KEY_NUM_LEN = 5;

    // =================================================== 数据质量模块 ============================================ //

    public static class DataQuality {
        /**
         * 内存中直接比较数据量阈值，2千万
         */
        public static final int BIG_DATA_THRESHOLD = 20000000;

        /**
         * 大数据量情况下拆分，每个桶中数据量大小, 一千万
         */
        public static final int SPLIT_THRESHOLD = 10000000;

        /**
         * 拉取数据处理批次数量
         */
        public static final int DEFAULT_STEP = 100000;

        /**
         * 最后一次查询数据库是否等待阈值，总数量，超过一百万则等待
         */
        public static final int WAIT_THRESHOLD = 1000000;

        /**
         * 处理数据线程数量
         */
        public static final int DEAL_FILE_THREAD_NUM = 3;
    }

    /**
     * 系统名称
     */
    public static final String SYSTEM_NAME = "MDM";

    public static final String[] MDM_EXCLUDE = {
            "ruoyi.", "sys_", "sso_", "QRTZ_", "oauth_", "message_", "markdown_", "gen_", "feedback_", "document_", "api_", "audit_", "ACT_", "act_", "bpm_", "flw_", "FLW_",
            "MDM_EditLog", "mdm_editlog", "data_", "dqc_", "etl_", "xxl_", "task_", "DR_", "dr_", "User_BTEventLog", "CB_BusinessTable", "word_", "infra_api_", "DE_", "de_",
            "CT_CodeSystem", "SS_", "ss_", "SM_", "sm_", "Manufacturer", "manufacturer", "doc_", "DOC_", "Ens_", "ens_",
            "CT_Marital", "CT_Occupation", "CT_Options", "Ens_Interface", "PatientConfig", "pa_account_info", "PA_Adm", "PA_MergePatientLog", "PA_SuspectPatient", "Rel_Adm", "rel_patient_account"
            , "t_"
    };

    public static final String[] MDM_LOG = {
            "CT_", "ct_", "HOS_", "hos_"
    };


    public static final String SCHEMA_NAME = "mdm_User";
    public static final String SCHEMA_NAME_ = "mdm_User.";

    public static final String DEFAULT_MDM_USER = "MDM-DEFAULT";

    // ===================================== 数据库字段 Start =============================================== //

    public static final String FIELD_BUSINESS_FIELD_CODE = "BusinessFieldCode";
    public static final String FIELD_MAP_USER_ID = "mapuserid";
    public static final String FIELD_DATE_LIKE = "Date";
    public static final String FIELD_END_DATE_LIKE = "EndDate";
    public static final String FIELD_TIME_LIKE = "Time";
    public static final String FIELD_USER_CODE_LIKE = "UserCode";
    public static final String FIELD_CODE_SYSTEM_LIKE = "_CodesystemCode";
    public static final String VALUES_LIST = "VALUELIST";
    public static final String DISPLAY_LIST = "DISPLAYLIST";


    // ===================================== 数据库字段 End =============================================== //


    /**
     * 排序规则：降序
     */
    public static final String ORDER_DESC = "desc";
    /**
     * 排序规则：升序
     */
    public static final String ORDER_ASC = "asc";

    /**
     * 允许下载的文件类型，根据需求自己添加（小写）
     */
    public static final String[] VALID_FILE_TYPE = {".xlsx", "zip"};


    /**
     * 默认父节点id
     */
    public static final String DEFAULT_ROOT = "0";
    public static final Long DEFAULT_PARENT = 0L;

    public static final String LOG_STR = "\n========================================== \n{} \n==========================================";

    /**
     * 合并患者状态（合并:M、取消合并：C）
     */
    public static final String PATIENT_MERGE_STATUS = "M";
    public static final String PATIENT_MERGE_CANCEL_STATUS = "C";

    /**
     * 相似权重code
     */
    public static final String SUSPECT_WIGHT_ID = "id";
    public static final String SUSPECT_WIGHT_NAME = "name";
    public static final String SUSPECT_WIGHT_SEX = "sex";
    public static final String SUSPECT_WIGHT_DOB = "dob";
    public static final String SUSPECT_WIGHT_TEL = "tel";
    public static final String SUSPECT_WIGHT_PHONE = "phone";


    // ============================================ 请求相关 =======================================//

    public static final String REQUEST_HEADER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel;charset=utf-8";

    public static final String STR_NULL = "null";

    public static final String FILE_DIR = "/TMP-Medical/mdm";

    /**
     * MDM线程池名称
     */
    public static final String MDM_THREAD_POOL = "threadPoolTaskExecutor";

    /**
     * 通用字典格式
     */
    public static final String DICT_GENERAL_STYLE = "{\"request\":{\"data\":{},\"tableCode\":\"{}\"}}";

    /**
     * 缓存相关
     */
    public static class RedisConst {

        public static final String DATA_QUALITY_COMPARE_TABLE_LIST = "data_quality:comparing";

        public static final String DATA_QUALITY_SOURCE_CACHE_C = "data_quality:{}-{}:source";

        public static final String DATA_QUALITY_TARGET_CACHE_C = "data_quality:{}-{}:target";

        public static final String DATA_QUALITY_SOURCE_CACHE_UNIQUE_C = "data_quality:{}-{}:source:{}";

        public static final String DATA_QUALITY_TARGET_CACHE_UNIQUE_C = "data_quality:{}-{}:target:{}";

        public static final String DATA_QUALITY_PLAN = "data_quality:plan:logId:{}";

        public static final String TABLE_INFO_CACHE = "table:{}:{}";
    }
}
